'''
Created on 2024年7月27日

@author: Administrator
'''


from pathlib import Path
import csv
import matplotlib.pyplot as plt

from datetime import datetime



# path = Path('sitka_weather_07-2014.csv')
path = Path('sitka_weather_2014.csv')
lines = path.read_text().splitlines()



reader = csv.reader(lines)
header_row = next(reader)
print(header_row)

for index,column_header in enumerate(header_row):
    print(index,column_header)

dates,highs,lows = [],[],[]
for row in reader:
    current_date = datetime.strptime(row[0],'%Y-%m-%d')
    high = int(row[1])
    low = int(row[3])
    dates.append(current_date)
    highs.append(high)
    lows.append(low)

print(highs)

plt.style.use('seaborn')
fig,ax = plt.subplots()
ax.plot(dates,highs,color='red',alpha=0.5)
ax.plot(dates,lows,color='blue',alpha=0.5)
ax.fill_between(dates,highs,lows,facecolor='blue',alpha=.1)


ax.set_title('Daily High Temperatures,July 2021',fontsize=24)
ax.set_xlabel('',fontsize=16)
fig.autofmt_xdate()
ax.set_ylabel('Temperature (F)',fontsize=16)
ax.tick_params(labelsize=16)

plt.show()


